package pe.edu.upc.dew.dao;

import java.util.List;

import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import pe.edu.upc.dew.model.Merchandizing;
import pe.edu.upc.dew.model.Pelicula;

@Repository
public class MerchandizingDaoJdbc extends SimpleJdbcDaoSupport implements MerchandizingDao{

	public List<Pelicula> getPeliculasParaCartelera() {
		String sql = "SELECT idPelicula,titulo,genero,synopsis,site,imagen,director,reparto,duracion,pais,estado,publico,subtitulos FROM pelicula WHERE estado = 1";
		return getSimpleJdbcTemplate().query(sql, new BeanPropertyRowMapper<Pelicula>(Pelicula.class));

	}

	@Override
	public List<Merchandizing> getTodosMerchandizing() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void eliminar(String id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Pelicula getMerchandizingPorId(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Merchandizing> getMerchandizingPorPelicula(String idPelicula) {
		String sql = "SELECT M.idMerchandizing,M.idPelicula,M.descripcion,M.caracteristica,M.imagen FROM TblMerchandizing M INNER JOIN pelicula P ON P.idPelicula=M.idPelicula	WHERE M.idPelicula=?";
		// TODO Auto-generated method stub
		return getSimpleJdbcTemplate().query(sql, new BeanPropertyRowMapper<Merchandizing>(Merchandizing.class), idPelicula);
		//return null;
	}

}
